package com.ruoyi.web.controller.manage;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.WorksShow;
import com.ruoyi.manage.service.IWorksShowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作品展示Controller
 * 
 * @author ruoyi
 * @date 2021-03-07
 */
@RestController
@RequestMapping("/manage/show")
public class WorksShowController extends BaseController
{
    @Autowired
    private IWorksShowService worksShowService;

    /**
     * 查询作品展示列表
     */
    @PreAuthorize("@ss.hasPermi('manage:show:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorksShow worksShow)
    {
        startPage();
        List<WorksShow> list = worksShowService.selectWorksShowList(worksShow);
        return getDataTable(list);
    }

    /**
     * 导出作品展示列表
     */
    @PreAuthorize("@ss.hasPermi('manage:show:export')")
    @Log(title = "作品展示", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorksShow worksShow)
    {
        List<WorksShow> list = worksShowService.selectWorksShowList(worksShow);
        ExcelUtil<WorksShow> util = new ExcelUtil<WorksShow>(WorksShow.class);
        return util.exportExcel(list, "show");
    }

    /**
     * 获取作品展示详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:show:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(worksShowService.selectWorksShowById(id));
    }

    /**
     * 新增作品展示
     */
    @PreAuthorize("@ss.hasPermi('manage:show:add')")
    @Log(title = "作品展示", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorksShow worksShow)
    {
        return toAjax(worksShowService.insertWorksShow(worksShow));
    }

    /**
     * 修改作品展示
     */
    @PreAuthorize("@ss.hasPermi('manage:show:edit')")
    @Log(title = "作品展示", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorksShow worksShow)
    {
        return toAjax(worksShowService.updateWorksShow(worksShow));
    }

    /**
     * 删除作品展示
     */
    @PreAuthorize("@ss.hasPermi('manage:show:remove')")
    @Log(title = "作品展示", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(worksShowService.deleteWorksShowByIds(ids));
    }
}
